package com.hzqy.web.ac;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hzqy.commons.utils.ConstantUtils;
import com.hzqy.service.weather.WeatherServiceBean;
import com.hzqy.web.vo.PmsUserVo;
import com.hzqy.web.vo.WeatherCommonVo;
import com.hzqy.web.vo.WeatherCommonVo;

@Controller
@RequestMapping("/")
public class WeatherAction {
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	
	@Resource
	private WeatherServiceBean weatherServiceBean;
	
	
	@RequestMapping("/weather/select_weather")
	@ResponseBody
	public Object selectWeatherCommonVo(String f_wfc_id) {
		WeatherCommonVo weatherCommonVo = weatherServiceBean.selectWeatherCommonVo(f_wfc_id);
		return weatherCommonVo;
	}
	
	@RequestMapping("/weather/weather_list")
	@ResponseBody
	public Object weatherList(ModelMap map,WeatherCommonVo weatherCommonVo, HttpSession session, int page, int rows) {
		Map<String,Object> weatherList = new HashMap<String, Object>();
		weatherList =  weatherServiceBean.selectWeatherCommonList(weatherCommonVo, page, rows);
		return weatherList;
	}
	

	@RequestMapping("/weather/insert_weather")
	@ResponseBody
	public Object insertWeather(WeatherCommonVo weatherCommonVo, HttpSession session) {
		Map<String,Object> resultMap = new HashMap<String,Object>();
		resultMap = weatherServiceBean.insertWeatherCommonVo(weatherCommonVo);
		return resultMap;
	}
	
	@RequestMapping("/weather/delete_weather")
	@ResponseBody
	public Object deleteWarn(String f_wfc_id, HttpSession session) {
		Map<String,Object> resultMap = new HashMap<String,Object>();
		int flag = weatherServiceBean.deleteWeatherCommonVo(f_wfc_id);
		resultMap.put("resultTitle", "删除结果");
		if(flag>0) {
			resultMap.put("success", true);
			resultMap.put("result","删除成功!");
		} else {
			resultMap.put("success", false);
			resultMap.put("result","删除失败!");
		}
		return resultMap;
	}
	
	@RequestMapping("/weather/update_weather")
	@ResponseBody
	public Object updateWeather( HttpSession session,WeatherCommonVo weatherCommonVo) {
		Map<String,Object> resultMap = new HashMap<String,Object>();
		resultMap = weatherServiceBean.updateWeather(weatherCommonVo);
		return resultMap;
	}
}
